package com.javatom.notes.feign.web;


import com.javatom.notes.common.User;
import com.javatom.notes.common.model.BaseResponse;
import com.javatom.notes.feign.service.FeignExternalService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/api/external")
@Slf4j
/**
 * 采用Feign调用调用外部服务
 */
public class FeignExternalServiceOperatControllor {
    @Resource
   private FeignExternalService feignExternalService;
   @Value("${spring.application.name}")
   private String applicationName;
    @Value("${server.port}")
    private String port;
  //  @ApiOperation(value = "测试mongo批量插入数据")

    /**
     * 调用百度的接口
     * @return
     */
   @RequestMapping(value = {"/search"}, method = {RequestMethod.GET})
   public BaseResponse<byte[]> search(String s) {
       log.error("applicationName {}",applicationName);

         byte[] a=feignExternalService.search(s);
      // log.error("initData {}",a.toString());
      return BaseResponse.success(a);
   }


}
